import React from 'react';
import { connect } from 'react-redux';
import { View, Image, Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import customerNo from '@/mainSubPack/images/customer/customerNo.png';
import './index.scss';

const ServiceResult = ({ className = '', CSsearchResultList = [] }) => {
  const handleArt = (id) => {
    Taro.navigateTo({ url: '/mainSubPack/customerServiceArticle/index?id=' + id });
  };
  return (
    <View className={'ServiceResult ' + className}>
      {CSsearchResultList && CSsearchResultList?.length > 0 ? (
        <View className="list">
          {CSsearchResultList.map((item) => {
            return (
              <View className="item" onClick={() => handleArt(item.id)} key={item.id}>
                {item.name}
              </View>
            );
          })}
        </View>
      ) : (
        <View className="flex-column--center noDate">
          <Image className="img" src={customerNo} />
          <Text className="text">抱歉，没有找到相关问题</Text>
        </View>
      )}
    </View>
  );
};

export default connect(({ otherApi }) => ({
  CSsearchResultList: otherApi.CSsearchResultList,
}))(ServiceResult);
